<template>
  <div class="left-block1">
    <div class="data-title">
      <a href="javascript:;" @click="download">工艺信息</a>
    </div>
    <div v-if="obj" class="process-info">
      <el-form label-width="100px" class="wise-form" label-suffix="：">
        <el-row>
          <el-col :span="12">
            <el-form-item label="焊接位置">
              {{ obj.welderPosition }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="焊接方向">
              {{ obj.welderDirection }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="预热温度">
              {{ obj.temperature }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="坡口形势">
              {{ obj.bevelSituation }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="层间温度">
              {{ obj.layerTemperature }}
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="焊接厚度">
              {{ obj.weldingThickness }}
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <el-table
        :data="tableData"
        border
        style="width: 100%"
        class="scroll-wrap"
      >
        <el-table-column
          prop="weldName"
          label="焊道"
          width="68px"
        />
        <el-table-column
          prop="weldMethod"
          label="焊接方法"
          width="68px"
        />
        <el-table-column
          prop="electricCurrentMin"
          label="电流"
          width="60px"
        >
          <template slot-scope="scope">
            {{ scope.row.electricCurrentMin }}-{{ scope.row.electricCurrentMax }}
          </template>
        </el-table-column>
        <el-table-column
          prop="voltageMin"
          label="电压"
          width="60px"
        >
          <template slot-scope="scope">
            {{ scope.row.voltageMin }}-{{ scope.row.voltageMax }}
          </template>
        </el-table-column>
        <el-table-column
          prop="weldingSpeedMin"
          label="焊接速度"
          width="60px"
        >
          <template slot-scope="scope">
            {{ scope.row.weldingSpeedMin }}-{{ scope.row.weldingSpeedMax }}
          </template>
        </el-table-column>
        <el-table-column
          prop="weldingHeatInputMin"
          label="焊接热输入"
        >
          <template slot-scope="scope">
            {{ scope.row.weldingHeatInputMin }}-{{ scope.row.weldingHeatInputMax }}
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
import { postHandle } from '@/api'
import { downloadHandle } from '@/api'
export default {
  name: 'ProcessInformation',
  data() {
    return {
      tableData: [],
      obj: {}
    }
  },
  created() {
    this.getData(this.$route.query.id)
  },
  methods: {
    getData(id) {
      postHandle(`/api/v1/welder-sbtx-second/project-info-comb/get-by-weld-info/${id}`).then(res => {
        this.obj = res.result
        this.tableData = res.result.weldInfoList
      })
    },
    download() {
      downloadHandle('doc/20200707.doc').then(res => {
        let fileName = '动火方案-广东管理处2020年西二线广深支干线SZHE162处管道环焊缝缺陷修复工程项目.doc'
        let blob = new Blob([res.data], { type: res.data.type })
        let downloadElement = document.createElement('a')
        let href = window.URL.createObjectURL(blob) // 创建下载的链接
        downloadElement.href = href
        downloadElement.download = fileName // 下载后文件名
        document.body.appendChild(downloadElement)
        downloadElement.click() // 点击下载
        document.body.removeChild(downloadElement) // 下载完成移除元素
        window.URL.revokeObjectURL(href) // 释放blob对象
      })
    }
  }
}
</script>

<style scoped>

</style>
